```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>快速排序算法可视化</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', 'Noto Serif SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background-color: #f8fafc;
            color: #1e293b;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
        }
        
        .code-block {
            background-color: #1e293b;
            border-left: 4px solid #8b5cf6;
        }
        
        .concept-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
        }
        
        .step-item:not(:last-child):after {
            content: "";
            position: absolute;
            left: 1.5rem;
            top: 2.5rem;
            height: calc(100% - 2.5rem);
            width: 2px;
            background-color: #cbd5e1;
        }
        
        .highlight {
            position: relative;
            z-index: 1;
        }
        
        .highlight:after {
            content: "";
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 30%;
            background-color: rgba(139, 92, 246, 0.2);
            z-index: -1;
            transform: rotate(-1deg);
        }
    </style>
</head>
<body class="min-h-screen">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-6">
        <div class="max-w-5xl mx-auto">
            <div class="flex flex-col md:flex-row items-center">
                <div class="md:w-1/2 mb-10 md:mb-0">
                    <h1 class="text-4xl md:text-5xl font-bold leading-tight mb-4">快速排序算法解析</h1>
                    <p class="text-xl md:text-2xl font-light mb-8">分而治之的高效排序艺术</p>
                    <div class="flex space-x-4">
                        <div class="bg-white bg-opacity-20 px-4 py-2 rounded-full">
                            <span class="text-sm font-medium">时间复杂度: O(n log n)</span>
                        </div>
                        <div class="bg-white bg-opacity-20 px-4 py-2 rounded-full">
                            <span class="text-sm font-medium">空间复杂度: O(log n)</span>
                        </div>
                    </div>
                </div>
                <div class="md:w-1/2 flex justify-center">
                    <div class="w-64 h-64 bg-white bg-opacity-10 rounded-xl backdrop-blur-sm p-6 flex items-center justify-center">
                        <div class="mermaid">
                            graph TD
                                A[快速排序] --> B[选择基准]
                                A --> C[分区]
                                A --> D[递归]
                                B --> E[最右元素]
                                B --> F[随机选择]
                                C --> G[小于基准]
                                C --> H[大于基准]
                                D --> I[左子数组]
                                D --> J[右子数组]
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="max-w-5xl mx-auto px-6 py-12">
        <!-- Introduction -->
        <section class="mb-16">
            <div class="flex items-center mb-6">
                <div class="w-12 h-12 bg-indigo-100 rounded-full flex items-center justify-center mr-4">
                    <i class="fas fa-lightbulb text-indigo-500 text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold text-slate-800">算法核心思想</h2>
            </div>
            <div class="bg-white rounded-xl shadow-md p-8">
                <p class="text-lg leading-relaxed mb-6">
                    快速排序是一种高效的<span class="highlight font-medium">分治排序算法</span>，其核心思想是通过选择一个"基准"元素将数组分成两个子数组：一个子数组的所有元素都比基准小，另一个子数组的所有元素都比基准大，然后递归地对这两个子数组进行排序。
                </p>
                <div class="grid md:grid-cols-2 gap-8">
                    <div>
                        <h3 class="text-xl font-semibold mb-4 text-indigo-600">优势特点</h3>
                        <ul class="space-y-3">
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                                <span>平均情况下时间复杂度为O(n log n)，效率极高</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                                <span>原地排序，空间复杂度仅为O(log n)</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                                <span>在实际应用中通常比其他O(n log n)算法更快</span>
                            </li>
                        </ul>
                    </div>
                    <div>
                        <h3 class="text-xl font-semibold mb-4 text-indigo-600">适用场景</h3>
                        <ul class="space-y-3">
                            <li class="flex items-start">
                                <i class="fas fa-database text-blue-500 mt-1 mr-2"></i>
                                <span>大规模数据排序</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-random text-blue-500 mt-1 mr-2"></i>
                                <span>对随机分布的数据排序效率最高</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-exclamation-triangle text-yellow-500 mt-1 mr-2"></i>
                                <span>不适用于已经基本有序的数据集</span>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </section>

        <!-- Algorithm Steps -->
        <section class="mb-16">
            <div class="flex items-center mb-6">
                <div class="w-12 h-12 bg-indigo-100 rounded-full flex items-center justify-center mr-4">
                    <i class="fas fa-list-ol text-indigo-500 text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold text-slate-800">算法执行步骤</h2>
            </div>
            
            <div class="relative">
                <!-- Step 1 -->
                <div class="step-item relative mb-12 pl-16">
                    <div class="absolute left-0 w-12 h-12 bg-indigo-500 rounded-full flex items-center justify-center text-white font-bold text-xl">1</div>
                    <div class="bg-white rounded-xl shadow-md p-8">
                        <h3 class="text-xl font-semibold mb-4 text-indigo-600">选择基准元素</h3>
                        <p class="text-slate-700 mb-4">
                            从当前排序区间中选择一个元素作为基准(pivot)。通常选择区间的最右元素作为基准，但也可以采用随机选择或其他策略以避免最坏情况。
                        </p>
                        <div class="bg-indigo-50 rounded-lg p-4">
                            <p class="font-mono text-indigo-800">
                                <span class="text-indigo-600">// 选择最右边的元素作为基准</span><br>
                                <span class="text-pink-500">int</span> pivot = nums[right];
                            </p>
                        </div>
                    </div>
                </div>
                
                <!-- Step 2 -->
                <div class="step-item relative mb-12 pl-16">
                    <div class="absolute left-0 w-12 h-12 bg-indigo-500 rounded-full flex items-center justify-center text-white font-bold text-xl">2</div>
                    <div class="bg-white rounded-xl shadow-md p-8">
                        <h3 class="text-xl font-semibold mb-4 text-indigo-600">分区操作</h3>
                        <p class="text-slate-700 mb-4">
                            重新排列数组，使得所有小于基准的元素都排在基准前面，所有大于基准的元素都排在基准后面。分区完成后，基准元素就位于其最终排序位置。
                        </p>
                        <div class="bg-indigo-50 rounded-lg p-4 mb-4">
                            <p class="font-mono text-indigo-800">
                                <span class="text-indigo-600">// i表示小于等于基准的元素的最后位置</span><br>
                                <span class="text-pink-500">int</span> i = left - 1;
                            </p>
                        </div>
                        <div class="mermaid">
                            graph LR
                                A[未分区数组] --> B[小于基准] 
                                A --> C[基准] 
                                A --> D[大于基准]
                        </div>
                    </div>
                </div>
                
                <!-- Step 3 -->
                <div class="step-item relative mb-12 pl-16">
                    <div class="absolute left-0 w-12 h-12 bg-indigo-500 rounded-full flex items-center justify-center text-white font-bold text-xl">3</div>
                    <div class="bg-white rounded-xl shadow-md p-8">
                        <h3 class="text-xl font-semibold mb-4 text-indigo-600">递归排序</h3>
                        <p class="text-slate-700 mb-4">
                            对基准左侧和右侧的两个子数组递归地应用相同的过程。递归的基准情况是子数组的大小小于等于1，此时数组已经是有序的。
                        </p>
                        <div class="bg-indigo-50 rounded-lg p-4">
                            <p class="font-mono text-indigo-800">
                                <span class="text-indigo-600">// 递归排序左半部分</span><br>
                                quickSortRecursive(nums, left, pivotIndex - 1);<br><br>
                                <span class="text-indigo-600">// 递归排序右半部分</span><br>
                                quickSortRecursive(nums, pivotIndex + 1, right);
                            </p>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Code Implementation -->
        <section class="mb-16">
            <div class="flex items-center mb-6">
                <div class="w-12 h-12 bg-indigo-100 rounded-full flex items-center justify-center mr-4">
                    <i class="fas fa-code text-indigo-500 text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold text-slate-800">Java 实现代码</h2>
            </div>
            
            <div class="code-block rounded-xl overflow-hidden shadow-lg">
                <div class="flex items-center bg-slate-800 px-4 py-3">
                    <div class="flex space-x-2 mr-4">
                        <div class="w-3 h-3 rounded-full bg-red-500"></div>
                        <div class="w-3 h-3 rounded-full bg-yellow-500"></div>
                        <div class="w-3 h-3 rounded-full bg-green-500"></div>
                    </div>
                    <span class="text-slate-300 text-sm">QuickSort.java</span>
                </div>
                <pre class="text-slate-100 p-6 overflow-x-auto"><code>public class QuickSort {
    /**
     * 快速排序主方法
     * @param nums 待排序数组
     * @return 排序后的数组
     */
    public int[] quickSort(int[] nums) {
        // 调用递归排序方法
        quickSortRecursive(nums, 0, nums.length - 1);
        return nums;
    }
    
    /**
     * 递归实现快速排序
     * @param nums 待排序数组
     * @param left 左边界
     * @param right 右边界
     */
    private void quickSortRecursive(int[] nums, int left, int right) {
        // 递归终止条件：区间长度为1或更小
        if (left < right) {
            // 获取分区点
            int pivotIndex = partition(nums, left, right);
            
            // 递归排序左半部分
            quickSortRecursive(nums, left, pivotIndex - 1);
            
            // 递归排序右半部分
            quickSortRecursive(nums, pivotIndex + 1, right);
        }
    }
    
    /**
     * 分区函数，将数组分为小于和大于基准的两部分
     * @param nums 待分区数组
     * @param left 左边界
     * @param right 右边界
     * @return 基准元素的最终位置
     */
    private int partition(int[] nums, int left, int right) {
        // 选择最右边的元素作为基准
        int pivot = nums[right];
        
        // i表示小于等于基准的元素的最后位置
        int i = left - 1;
        
        // 遍历区间内的所有元素（除了基准）
        for (int j = left; j < right; j++) {
            // 如果当前元素小于等于基准，将其交换到前面
            if (nums[j] <= pivot) {
                i++;
                // 交换元素
                swap(nums, i, j);
            }
        }
        
        // 将基准元素放到正确的位置
        swap(nums, i + 1, right);
        
        // 返回基准元素的位置
        return i + 1;
    }
    
    /**
     * 交换数组中的两个元素
     * @param nums 数组
     * @param i 第一个元素的索引
     * @param j 第二个元素的索引
     */
    private void swap(int[] nums, int i, int j) {
        int temp = nums[i];
        nums[i] = nums[j];
        nums[j] = temp;
    }
}</code></pre>
            </div>
        </section>

        <!-- Complexity Analysis -->
        <section>
            <div class="flex items-center mb-6">
                <div class="w-12 h-12 bg-indigo-100 rounded-full flex items-center justify-center mr-4">
                    <i class="fas fa-chart-line text-indigo-500 text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold text-slate-800">复杂度分析</h2>
            </div>
            
            <div class="grid md:grid-cols-3 gap-6">
                <div class="bg-white rounded-xl shadow-md p-6 transition-all duration-300 hover:shadow-lg">
                    <div class="flex items-center mb-4">
                        <div class="w-10 h-10 bg-blue-100 rounded-full flex items-center justify-center mr-3">
                            <i class="fas fa-clock text-blue-500"></i>
                        </div>
                        <h3 class="text-lg font-semibold">时间复杂度</h3>
                    </div>
                    <div class="space-y-2">
                        <div class="flex justify-between items-center">
                            <span class="text-sm font-medium text-slate-600">最佳情况</span>
                            <span class="px-2 py-1 bg-green-100 text-green-800 rounded-full text-xs font-medium">O(n log n)</span>
                        </div>
                        <div class="flex justify-between items-center">
                            <span class="text-sm font-medium text-slate-600">平均情况</span>
                            <span class="px-2 py-1 bg-blue-100 text-blue-800 rounded-full text-xs font-medium">O(n log n)</span>
                        </div>
                        <div class="flex justify-between items-center">
                            <span class="text-sm font-medium text-slate-600">最坏情况</span>
                            <span class="px-2 py-1 bg-red-100 text-red-800 rounded-full text-xs font-medium">O(n²)</span>
                        </div>
                    </div>
                </div>
                
                <div class="bg-white rounded-xl shadow-md p-6 transition-all duration-300 hover:shadow-lg">
                    <div class="flex items-center mb-4">
                        <div class="w-10 h-10 bg-purple-100 rounded-full flex items-center justify-center mr-3">
                            <i class="fas fa-memory text-purple-500"></i>
                        </div>
                        <h3 class="text-lg font-semibold">空间复杂度</h3>
                    </div>
                    <p class="text-sm text-slate-600 mb-2">快速排序是原地排序算法，但递归调用会占用栈空间。</p>
                    <div class="flex justify-between items-center">
                        <span class="text-sm font-medium text-slate-600">递归深度</span>
                        <span class="px-2 py-1 bg-indigo-100 text-indigo-800 rounded-full text-xs font-medium">O(log n)</span>
                    </div>
                </div>
                
                <div class="bg-white rounded-xl shadow-md p-6 transition-all duration-300 hover:shadow-lg">
                    <div class="flex items-center mb-4">
                        <div class="w-10 h-10 bg-amber-100 rounded-full flex items-center justify-center mr-3">
                            <i class="fas fa-balance-scale text-amber-500"></i>
                        </div>
                        <h3 class="text-lg font-semibold">稳定性</h3>
                    </div>
                    <p class="text-sm text-slate-600 mb-2">快速排序不是稳定的排序算法，因为相等的元素可能会因为分区而改变相对顺序。</p>
                    <div class="flex justify-between items-center">
                        <span class="text-sm font-medium text-slate-600">稳定性</span>
                        <span class="px-2 py-1 bg-amber-100 text-amber-800 rounded-full text-xs font-medium">不稳定</span>
                    </div>
                </div>
            </div>
        </section>
    </main>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'dark',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            },
            themeVariables: {
                primaryColor: '#3b82f6',
                primaryTextColor: '#ffffff',
                primaryBorderColor: '#3b82f6',
                lineColor: '#8b5cf6',
                textColor: '#ffffff',
                fontSize: '14px'
            }
        });
    </script>
</body>
</html>
```